﻿using PHMEE.ToolKits;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PHMEE.Entities.BaseInfo.Units
{
    /// <summary>
    /// 滑油分油机机组
    /// </summary>
    public class LubricatingOilSepaUnit : Unit
    {

        protected LubricatingOilSepaUnit()
        {

        }
        public LubricatingOilSepaUnit(Guid id, Guid vesselId, string name, string nameen, int number) : base(id, vesselId, name, nameen, number)
        {

        }

        /// <summary>
        /// 加速度峰值阈值
        /// </summary>
        [NotMapped]
        public double Acc { get; set; }

        /// <summary>
        /// 电机速度rms阈值
        /// 1
        /// </summary>
        [NotMapped]
        public double MrmsA { get; set; }

        /// <summary>
        /// 电机速度rms阈值
        /// 2
        /// </summary>
        [NotMapped]
        public double MrmsB { get; set; }

        /// <summary>
        /// 电机速度rms阈值
        /// 3
        /// </summary>
        [NotMapped]
        public double MrmsC { get; set; }

        /// <summary>
        /// 速度谱1x频幅值
        /// 1
        /// </summary>
        [NotMapped]
        public double Value1XA { get; set; }

        /// <summary>
        /// 速度谱1x频幅值
        /// 2
        /// </summary>
        [NotMapped]
        public double Value1XB { get; set; }

        /// <summary>
        /// 轴承内圈故障判断阈值
        /// </summary>
        [NotMapped]
        public double BearA { get; set; }

        /// <summary>
        /// 轴承外圈故障判断阈值
        /// </summary>
        [NotMapped]
        public double BearB { get; set; }

        /// <summary>
        /// 轴承滚动体故障判断阈值
        /// </summary>
        [NotMapped]
        public double BearC { get; set; }

        /// <summary>
        /// 轴承保持架故障判断阈值
        /// </summary>
        [NotMapped]
        public double BearD { get; set; }

        /// <summary>
        /// 轴承跑圈故障判断阈值
        /// 1
        /// </summary>
        [NotMapped]
        public double BearE1 { get; set; }

        /// <summary>
        /// 轴承跑圈故障判断阈值
        /// 2
        /// </summary>
        [NotMapped]
        public double BearE2 { get; set; }

        /// <summary>
        /// 轴承跑圈故障判断阈值
        /// 3
        /// </summary>
        [NotMapped]
        public double BearE3 { get; set; }

        /// <summary>
        /// 轴承跑圈故障判断阈值
        /// 4
        /// </summary>
        [NotMapped]
        public double BearE4 { get; set; }

        /// <summary>
        /// 轴承跑圈故障判断阈值
        /// 5
        /// </summary>
        [NotMapped]
        public double BearE5 { get; set; }

        /// <summary>
        /// 电枢故障判断阈值
        /// 1
        /// </summary>
        [NotMapped]
        public double ArmatureFaultA { get; set; }

        /// <summary>
        /// 电枢故障判断阈值
        /// 2
        /// </summary>
        [NotMapped]
        public double ArmatureFaultB { get; set; }

        /// <summary>
        /// 共振故障判断阈值
        /// </summary>
        [NotMapped]
        public double ResonanceFault { get; set; }

        /// <summary>
        /// 结构松动故障判断阈值
        /// </summary>
        [NotMapped]
        public double StructureLoose { get; set; }

        /// <summary>
        /// 联轴器失中故障判断阈值
        /// 1
        /// </summary>
        [NotMapped]
        public double MisalignmentA { get; set; }

        /// <summary>
        /// 联轴器失中故障判断阈值
        /// 2
        /// </summary>
        [NotMapped]
        public double MisalignmentB { get; set; }

        /// <summary>
        /// 横轴端速度rms阈值
        /// 1
        /// </summary>
        [NotMapped]
        public double HrmsA { get; set; }

        /// <summary>
        /// 横轴端速度rms阈值
        /// 2
        /// </summary>
        [NotMapped]
        public double HrmsB { get; set; }

        /// <summary>
        /// 横轴端速度rms阈值
        /// 3
        /// </summary>
        [NotMapped]
        public double HrmsC { get; set; }

        /// <summary>
        /// 不平衡故障判断阈值
        /// </summary>
        [NotMapped]
        public double ImbalanceFault { get; set; }

        /// <summary>
        /// 螺旋齿损伤故障
        /// 1
        /// </summary>
        [NotMapped]
        public double SpiralGearA { get; set; }

        /// <summary>
        /// 螺旋齿损伤故障
        /// 2
        /// </summary>
        [NotMapped]
        public double SpiralGearB { get; set; }

        /// <summary>
        /// 螺旋齿损伤故障
        /// 3
        /// </summary>
        [NotMapped]
        public double SpiralGearC { get; set; }

        /// <summary>
        /// 螺旋齿损伤故障
        /// 4
        /// </summary>
        [NotMapped]
        public double SpiralGearD { get; set; }

        /// <summary>
        /// 螺旋齿啮合不良故障
        /// </summary>
        [NotMapped]
        public double SpiralGearPoorMeshing { get; set; }

        public override void SerializeProperties(Dictionary<string, object> derivedPropertiesJson)
        {
            var properties = PHMEECoreHelper.GetDerivedProperties(this);
            this.DerivedPropertiesJson = derivedPropertiesJson.Where(item => properties.Keys.Any(p => string.Equals(p, item.Key, StringComparison.OrdinalIgnoreCase))).ToDictionary();
        }

        public override void DeserializeProperties()
        {
            PHMEECoreHelper.SetDerivedProperties(this, DerivedPropertiesJson);
        }

        public override Dictionary<string, object> InitDefaultProperties()
        {
            Dictionary<string, object> dict = new Dictionary<string, object>
            {
                { nameof(Acc), 8.0 },
                { nameof(MrmsA), 2.8 },
                { nameof(MrmsB), 4.5 },
                { nameof(MrmsC), 7.1 },
                { nameof(Value1XA), 20.0 },
                { nameof(Value1XB), 30.0 },
                { nameof(BearA), 0.4 },
                { nameof(BearB), 0.4 },
                { nameof(BearC), 0.4 },
                { nameof(BearD), 0.4 },
                { nameof(BearE1), 0.7 },
                { nameof(BearE2), 0.3 },
                { nameof(BearE3), 0.3 },
                { nameof(BearE4), 0.3 },
                { nameof(BearE5), 8.0 },
                { nameof(ArmatureFaultA), 0.7 },
                { nameof(ArmatureFaultB), 0.4 },
                { nameof(ResonanceFault), 0.7 },
                { nameof(StructureLoose), 0.7 },
                { nameof(ImbalanceFault), 0.5 },
                { nameof(MisalignmentA), 0.3 },
                { nameof(MisalignmentB), 2.8 },
                { nameof(HrmsA), 4.5 },
                { nameof(HrmsB), 7.1 },
                { nameof(HrmsC), 0.7 },
                { nameof(SpiralGearA), 0.7 },
                { nameof(SpiralGearB), 0.3 },
                { nameof(SpiralGearC), 0.3 },
                { nameof(SpiralGearD), 0.3 },
                { nameof(SpiralGearPoorMeshing), 0.7 }
            };

            return dict;
        }
    }
}
